package com.crx.springbootinit.controller.admin;

import com.crx.springbootinit.annotation.AuthCheck;
import com.crx.springbootinit.annotation.LogApiAnno;
import com.crx.springbootinit.common.BaseResponse;
import com.crx.springbootinit.common.ResultUtils;
import com.crx.springbootinit.model.dto.collect.CollectPageDTO;
import com.crx.springbootinit.model.dto.page.PageVO;
import com.crx.springbootinit.model.vo.collect.CollectMyPostVO;
import com.crx.springbootinit.service.ICollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 谢杭延
 * @Date 2024-11-01 12:50
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/collect")
@Api(tags = "后台收藏模块接口")
public class CollectAdminController {

    private final ICollectService collectService;

    @DeleteMapping("/delete/{ids}")
    @ApiOperation("删除收藏")
    @LogApiAnno(title = "收藏模块", businessType = "DELETE")
    @AuthCheck
    public BaseResponse<Void> deleteCollect(@ApiParam("收藏id列表") @PathVariable List<Long> ids){
        collectService.removeByIds(ids);
        return BaseResponse.success();
    }

    @GetMapping("/page")
    @ApiOperation("分页查询收藏列表")
    @LogApiAnno(title = "收藏模块", businessType = "GET")
    @AuthCheck
    public BaseResponse<PageVO<CollectMyPostVO>> queryCollectPage(CollectPageDTO collectPageDTO){
        PageVO<CollectMyPostVO> pageVO = collectService.queryCollectPage(collectPageDTO);
        return BaseResponse.success(pageVO);
    }
}
